// Implementation of Wu Manber's Multi-Pattern Search Algorithm
// Implemented by Ray Burkholder, ray@oneunified.net
// Copyright (2008) One Unified
// For use without restriction but one:  this copyright notice must be preserved.

//#include "StdAfx.h"

#include "WuManber.h"
#include <time.h>
#include <string.h>
#include <string>
#include <iostream>

#define N 1000

using namespace std;

int main()
{
  int n;
  string target,strin;
  vector<const char *> patterns;

  cin>>n;
  for(int i=0;i<n;++i)
  {
    cin>>strin;
    char *buf = new char[strin.length()];
    strcpy(buf,strin.c_str());
    patterns.push_back(buf);
  }
  cin>>target;
  WuManber search;
  clock_t s = clock(),t1,t2;
  search.Initialize(patterns);
  t1 = clock();
  search.Search(strlen(target.c_str()), target.c_str(), patterns);
  t2 = clock();
  double d1 = t1-s, d2 = t2-t1;
  d1 = d1/CLOCKS_PER_SEC*1000;
  d2 = d2/CLOCKS_PER_SEC*1000;
  cout<<d1<<"\t"<<d2<<"\t"<<d1+d2<<endl;
  return 0;
}